#!/usr/bin/env python

from lxml import etree
import urllib, sys
import json

results = []
for page in range(1, 9):
    print >>sys.stderr, page
    fd = urllib.urlopen('http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=c011447993de5f3b51bcde87c9c19cee&tags=rabbit%2Cbunny&tag_mode=any&privacy_filter=1&content_type=1&license=5&extras=owner_name&per_page=500' + '&page=%d' % page)
    et = etree.parse(fd)
    for photo in et.xpath('/rsp/photos/photo'):
        def g(k):
            return photo.get(k)
        results.append(map(g, ['farm', 'server', 'id', 'secret', 'ownername', 'title', 'owner']))
print "var rabbits = ", 
json.dump(results, sys.stdout)
print ";"
